package main

import (
	"fmt"
	"strconv"
)

func main() {

	var str string = "true"
	var b bool
	b, _ = strconv.ParseBool(str)
	fmt.Printf("b type is %T b=%v\n", b, b)

	var str1 string = "521463"
	num, _ := strconv.ParseInt(str1, 10, 64) //默认返回两个 且是int64类型
	fmt.Printf("num type is %T num=%v\n", num, num)

	str2 := "13456.36"
	num1, _ := strconv.ParseFloat(str2, 64) //默认返回两个 且是float64类型
	fmt.Printf("num1 type is %T num1=%v\n", num1, num1)

	//特殊情况 bool没转成功就是默认值false ,同理int和float就是0
	str3 := "hello"
	var num2 int64 = 100
	num2, _ = strconv.ParseInt(str3, 10, 64)
	fmt.Printf("num2 type is %T num2=%v\n", num2, num2)

	str4 := "hello"
	num3, _ := strconv.ParseBool(str4)
	fmt.Printf("num3 type is %T num3=%v\n", num3, num3)

}
